package com.heyige.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("users")
public class User {
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    @TableField("username")
    private String username;
    
    @TableField("email")
    private String email;
    
    @TableField("phone")
    private String phone;
    
    @TableField("password")
    @JsonIgnore
    private String password;
    
    @TableField("avatar")
    private String avatar;
    
    @TableField("wx_openid")
    private String wxOpenid;
    
    @TableField("wx_unionid")
    private String wxUnionid;
    
    @TableField("mini_program_openid")
    private String miniProgramOpenid;
    
    @TableField("last_login_time")
    private LocalDateTime lastLoginTime;
    
    @TableField("login_count")
    private Integer loginCount = 0;
    
    @TableField("is_vip")
    private Boolean isVip = false;
    
    @TableField("vip_expire_time")
    private LocalDateTime vipExpireTime;
    
    @TableField("status")
    private String status = UserStatus.ACTIVE.name();
    
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updatedAt;
    
    public enum UserStatus {
        ACTIVE, INACTIVE, BANNED
    }
}